package com.zyt.k8stest.controller;

import com.zyt.k8stest.mapper.K8sMapper;
import com.zyt.k8stest.model.K8stest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yongting zhang
 * @date 2020-11-23 09:18
 */
@RestController
@RequestMapping("/k8s")
public class K8STestController {
    @Autowired
    private K8sMapper k8sMapper;

    @RequestMapping("/test")
    public String test() {
        return "k8s test";
    }

    @RequestMapping("/selectAll")
    public List<K8stest> selectAll() {
        return k8sMapper.selectList(null);
    }

    @RequestMapping("/insert/{name}/{age}")
    public Boolean selectAll(@PathVariable String name, @PathVariable Integer age) {
        K8stest k8stest = new K8stest();
        k8stest.setName(name);
        k8stest.setAge(age);
        return k8sMapper.insert(k8stest) == 1;
    }

    @RequestMapping("/delete/{id}")
    public Boolean selectAll(@PathVariable Long id) {
        return k8sMapper.deleteById(id) == 1;
    }
}
